'use strict';

import Base from './base.js';
import crontab from 'node-crontab';

var async = require('async');

/*var crontab = require('crontab');*/

export default class extends Base {
  /**
   * index action
   * @return {Promise} []
   */
  
  indexAction(){
   /* var  wea = require('../service/weaService');
    wea.getCityAll();*/

   /* var ff = require('../service/test');
    ff.orientotest();*/
    /*var async = require('async');
    async.series([wea.orientotest(),wea.odata()]);*/
    /*wea.orientotest(function(data){
        console.log('---------------我的这个事data-----------',data);
    });*/
  

    //let bb = wea.getWeather();
    return this.display();
  }
  //定时任务，每1小时执行一次
  taskAction(){
    var  wea = require('../service/weaService');
    var cityList = this.post("cityList");
    let jobId = crontab.scheduleJob('0 */1 * * *', function () {
      wea.getCityAll();
    });
    return this.display();
  }

  getcitylistAction(){
    var  wea = require('../service/weaService');
    var list = [];
    wea.getCityAll1(this);
  }

  addcityAction(){
     var  wea = require('../service/weaService');
     var name = this.get('name');
     var time = this.get('time');
     var pinyin = this.get('pinyin');
     wea.addCity(name,time,pinyin);
     return this.success("true");
  }
  
  /*testAction(data){
    console.log('---------------我的这个事data-----------',data);
    return this.success(list);
  }*/


}